/*
 * HTMLDocument.cpp
 *
 *  Created on: 2010-6-10
 *      Author: guobc
 */

#include "HTMLDocument.h"

namespace HA {

HTMLDocument::HTMLDocument() :
	HA::ASTDom(), mRoot(NULL) {

}

bool HTMLDocument::open(const string& htmlName) {
	mLexer = new HTMLLexer(htmlName);
	return mLexer->open();
}

void HTMLDocument::close() {
	mLexer->close();
	mLexer = NULL;
}

void HTMLDocument::parse() throw (exception) {
	try {
		if (mLexer != NULL) {
			Parser* parser = new HTMLParser(mLexer);
			parser->parse();
			mRoot = dynamic_cast<Element*> (parser->getRootNode());
		}
	} catch (exception& e) {
		throw e;
	}
}
}
